package com.alfayun.fiscalriskanalysis.reportspec;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.alfayun.fiscalriskanalysis.report.ReportPeriod;

@Entity
@Table(name = "report_spec")
public class ReportSpec {
	
        @Column(name = "report_spec_id", updatable = false)
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Id
        private Integer id;
        public String name;
        public String reportIndex;//编号
        @Enumerated(EnumType.STRING)
        public ReportType reportType;//报表类别(如财务报表等)
        @Enumerated(EnumType.STRING)
        public ReportPeriod period;//报表期(季度、月度等)
        //public Set<String> tags;
        public boolean showRowNum;
        public boolean showColumnNum;
        @ManyToOne(cascade = CascadeType.DETACH)
        @JoinColumn(name = "report_template_id")
        public ReportTemplate template;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	public static ReportSpec newReportSpec(ReportSpecRepository repository, ReportSpec reportSpec) {
		reportSpec.id = 0;

		return repository.save(reportSpec);
	}

}
